#include "const.h"

var_t v_newhash(var_t prnt, const char *name, uint32_t hash) {
	size_t i;
	var_t v;

	if (!prnt)
		prnt = g_var_root;

	v = (var_t)i_new(sizeof(*v));

	v->name = i_strdup(name);
	v->hash = hash;

	v->flags = 0;

	v->value.text = (char *)0;
	v->expanded = (char *)0;

	v->array.members = (char **)0;
	v->array.n_text[0] = 0;
	v->array.i_text[0] = 0;
	v->array.capacity = 0;
	v->array.n = 0;
	v->array.i = 0;
	v->array.ptrvar = (var_t)0;

	for(i=0; i<VAR_MAX_INHERITENCE; i++)
		v->i.owners[i] = (var_t)0;
	v->i.owned_index = 0;
	v->i.owned = (var_t)0;

	v->h.prnt = prnt;
	v->h.head = (var_t)0;
	v->h.tail = (var_t)0;
	v->h.next = (var_t)0;
	if ((v->h.prev = prnt->h.tail) != (var_t)0)
		prnt->h.tail->h.next = v;
	else
		prnt->h.head = v;
	prnt->h.tail = v;

	return v;
}
